package com.ego.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.slf4j.Logger;

/**
 * @author Ares
 * @date 2020-11-24
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class EgoException extends RuntimeException {
    private Integer errorCode;
    private String errorMessage;

    public EgoException(IException iException) {
        this.errorCode = iException.getCode();
        this.errorMessage = iException.getMessage();
    }

    public static void error(Logger logger,IException e,Exception source){
        logger.error("异常码[{}],异常提示[{}],异常详情:", e.getCode(), e.getMessage(),source);
        throw new EgoException(e);
    }

    public static void error(Logger logger,IException e){
        logger.error("异常码[{}],异常提示[{}]", e.getCode(), e.getMessage());
        throw new EgoException(e);
    }
}
